/****************************************************************************************
 * @file    usart.h
 * 
 * @author  Shanon
 *
 * @version V1.0.0
 *
 * @date    02-08-2016
 *
 * @brief   usart header file.
 ***************************************************************************************/
#ifndef _USART_H
#define _USART_H

#include "stm32f4xx.h"

/****************************************************************************************
 * Definition for COM port1, connected to USART1
 ***************************************************************************************/
#define Open_USART1                        USART1
#define Open_USART1_CLK                    RCC_APB2Periph_USART1
/* Transmit pin definition */
#define Open_USART1_TX_PIN                 GPIO_Pin_9
#define Open_USART1_TX_GPIO_PORT           GPIOA
#define Open_USART1_TX_GPIO_CLK            RCC_AHB1Periph_GPIOA
#define Open_USART1_TX_SOURCE              GPIO_PinSource9
#define Open_USART1_TX_AF                  GPIO_AF_USART1
/* Receive pin definition */
#define Open_USART1_RX_PIN                 GPIO_Pin_10
#define Open_USART1_RX_GPIO_PORT           GPIOA
#define Open_USART1_RX_GPIO_CLK            RCC_AHB1Periph_GPIOA
#define Open_USART1_RX_SOURCE              GPIO_PinSource10
#define Open_USART1_RX_AF                  GPIO_AF_USART1
/* Interrupt definition */
#define Open_USART1_IRQn                   USART1_IRQn
#define USART1_IRQHANDLER  				   USART1_IRQHandler


/****************************************************************************************
 * Definition for COM port2, connected to USART2
 ***************************************************************************************/
#define Open_USART2                        USART2
#define Open_USART2_CLK                    RCC_APB1Periph_USART2

#define Open_USART2_TX_PIN                 GPIO_Pin_2
#define Open_USART2_TX_GPIO_PORT           GPIOA
#define Open_USART2_TX_GPIO_CLK            RCC_AHB1Periph_GPIOA
#define Open_USART2_TX_SOURCE              GPIO_PinSource2
#define Open_USART2_TX_AF                  GPIO_AF_USART2


#define Open_USART2_RX_PIN                 GPIO_Pin_3
#define Open_USART2_RX_GPIO_PORT           GPIOA
#define Open_USART2_RX_GPIO_CLK            RCC_AHB1Periph_GPIOA
#define Open_USART2_RX_SOURCE              GPIO_PinSource3
#define Open_USART2_RX_AF                  GPIO_AF_USART2

#define Open_USART2_IRQn                   USART2_IRQn
#define USART2_IRQHANDLER  				   USART2_IRQHandler

/****************************************************************************************
 * Definition for COM port3, connected to USART3
 ***************************************************************************************/
#define Open_USART3                        USART3
#define Open_USART3_CLK                    RCC_APB1Periph_USART3

#define Open_USART3_TX_PIN                 GPIO_Pin_10
#define Open_USART3_TX_GPIO_PORT           GPIOC
#define Open_USART3_TX_GPIO_CLK            RCC_AHB1Periph_GPIOC
#define Open_USART3_TX_SOURCE              GPIO_PinSource10
#define Open_USART3_TX_AF                  GPIO_AF_USART3


#define Open_USART3_RX_PIN                 GPIO_Pin_11
#define Open_USART3_RX_GPIO_PORT           GPIOC
#define Open_USART3_RX_GPIO_CLK            RCC_AHB1Periph_GPIOC
#define Open_USART3_RX_SOURCE              GPIO_PinSource11
#define Open_USART3_RX_AF                  GPIO_AF_USART3

#define Open_USART3_IRQn                   USART3_IRQn
#define USART3_IRQHANDLER  				   USART3_IRQHandler

/****************************************************************************************
 * Definition for COM port6, connected to USART6
 ***************************************************************************************/
#define Open_USART6                        USART6
#define Open_USART6_CLK                    RCC_APB2Periph_USART6

#define Open_USART6_TX_PIN                 GPIO_Pin_6
#define Open_USART6_TX_GPIO_PORT           GPIOC
#define Open_USART6_TX_GPIO_CLK            RCC_AHB1Periph_GPIOC
#define Open_USART6_TX_SOURCE              GPIO_PinSource6
#define Open_USART6_TX_AF                  GPIO_AF_USART6


#define Open_USART6_RX_PIN                 GPIO_Pin_7
#define Open_USART6_RX_GPIO_PORT           GPIOC
#define Open_USART6_RX_GPIO_CLK            RCC_AHB1Periph_GPIOC
#define Open_USART6_RX_SOURCE              GPIO_PinSource7
#define Open_USART6_RX_AF                  GPIO_AF_USART6

#define Open_USART6_IRQn                   USART6_IRQn
#define USART6_IRQHANDLER  				   USART6_IRQHandler

/****************************************************************************************
 * usart Function Prototypes
 ***************************************************************************************/
void USART1_Init( void );

void USART1_NVIC_Config( void );

void USART2_Init( void );

void USART2_NVIC_Config( void );

void USART3_Init( void );

void USART3_NVIC_Config( void );

void USART6_Init( void );

void USART6_NVIC_Config( void );

extern float OutData[4];

extern uint8_t OutPut_Data(void);

#endif /*_USART_H*/

